import {Component, EventEmitter, Inject, Input, OnInit, Output} from '@angular/core';
import OlView from 'ol/View';
import {BaseComponent} from '../../entity/base-component';
import {BaseMapComponent} from '../../base-map/base-map.component';

@Component({
    selector: 'map-full-screen',
    templateUrl: './map-full-screen.component.html',
    styleUrls: ['./map-full-screen.component.less']
})
export class MapFullScreenComponent implements OnInit, BaseComponent {

    @Output()
    closeEvent = new EventEmitter<any>();
    private view: OlView;
    private mapContainer: HTMLElement;

    constructor(@Inject(BaseMapComponent) public readonly baseMap: BaseMapComponent) {
        this.view = baseMap.map.view;
    }

    triggerClose() {
        this.closeEvent.emit();
    }


    ngOnInit() {
    }

    fullScreen() {
        this.mapContainer.requestFullscreen();
    }

    exitFullScreen() {
        document.exitFullscreen();
    }

    isFullScreen() {
        return !!document.fullscreenElement;
    }
}
